package compare;

/**
 * @author : DuJiabao
 * @Date : 2021/1/21 23:19
 * @Project : java_learning
 * @File : null.java
 * @Desc :
 */
public class Commodity implements Comparable<Commodity> {
    private int price = 0;

    public Commodity() {
    }

    public Commodity(int price) {
        this.price = price;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    @Override
    public int compareTo(Commodity o) {
        return Integer.compare(this.price, o.getPrice());
    }

    @Override
    public String toString() {
        return "Commodity{" +
                "price=" + price +
                '}';
    }
}
